<template>
  <div style="padding: 10px;">
    <el-row>
      <el-col :span="20">
        <el-form inline :model="form_data" ref="searchForm">

          <el-form-item prop="project">
            <el-input placeholder="搜索项目" v-model="form_data.project"></el-input>
          </el-form-item>
          <el-form-item prop="customer">
            <el-input placeholder="搜索客户" v-model="form_data.customer"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="getData" size="mini" type="primary">搜索</el-button>
            <el-button @click="resetData" size="mini">重置</el-button>
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="4" style="text-align: right;">
        <div style="display: flex;justify-content: flex-end;width: 100%;">
          <el-upload
            class="upload-demo"
            :action="uploadUrl" :headers="headers" :show-file-list="false"
          >
            <el-button  type="primary" size="mini" style="margin-right: 10px;">导入</el-button>
          </el-upload>
<!--          <el-button type="primary" size="mini" @click="exportsData" >导出</el-button>-->
        </div>
      </el-col>
      <el-col>
        <el-table :data="table_data" :height="table_height" >
          <el-table-column label="序号" prop="sequenceNumber" ></el-table-column>
          <el-table-column label="科目编码" prop="subjectCode" ></el-table-column>
          <el-table-column label="科目" prop="subjectName" ></el-table-column>
          <el-table-column label="项目" prop="project" ></el-table-column>
          <el-table-column label="客户" prop="customer" ></el-table-column>
          <el-table-column label="供应商" prop="supplier" ></el-table-column>
          <el-table-column label="存货" prop="inventory" ></el-table-column>
          <el-table-column label="凭证日期" prop="voucherDate" ></el-table-column>
          <el-table-column label="凭证号" prop="voucherNumber" ></el-table-column>
          <el-table-column label="摘要" prop="summary" ></el-table-column>
          <el-table-column label="借方金额" prop="debitAmount" ></el-table-column>
          <el-table-column label="贷方金额" prop="creditAmount" ></el-table-column>
          <el-table-column label="方向" prop="direction" ></el-table-column>
          <el-table-column label="余额" prop="balance" ></el-table-column>
          <el-table-column label="备注" prop="remark" ></el-table-column>
        </el-table>

        <pagination
          v-show="list_total>0"
          :total="list_total"
          :page.sync="list_params.pageNum"
          :limit.sync="list_params.pageSize"
          @pagination="getData"
        />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  accountingEntryList,
  accountingEntryPage,
  accountingEntryStatistics,
  accountingEntryStatisticsPage, accountingEntryPageExport
} from '@/api/report/report'
import { getToken } from '@/utils/auth'
export default {
  name: "settlement_fruit",
  dicts:['order_product_type','logistics_type'],
  data(){
    return {
      table_height:window.innerHeight - 300,
      list_params: {
        pageNum: 1,
        pageSize: 10,
        customer:'',
        subjectName:'',
      },
      list_total:0,
      uploadUrl: process.env.VUE_APP_BASE_API + "/xnf/accounting/entry/import",
      headers: {
        Authorization: "Bearer " + getToken(),
      },
      loadingTime:'',
      table_data:[],
      form_data:{
        project:'',
        customer:'',
      },
      product_list:[]
    }
  },
  created(){
    this.getData()
  },
  methods:{

    resetData(){
      this.$refs.searchForm.resetFields()
      this.getData()
    },
    getData() {
      let params = {
        ...this.form_data,
        pageNum:this.list_params.pageNum,
        pageSize:this.list_params.pageSize
      }
      console.log(params)
      debugger
      accountingEntryPage(params).then(res=>{
        this.table_data = res.rows
        this.list_total = res.total
      })
    },
    exportsData(){
      accountingEntryPageExport(this.form_data).then(res=>{
        const url= window.URL.createObjectURL(new Blob([res]));
        const link= document.createElement('a');
        link.href = url;
        link.download =`客户往来账查询_${new Date().getTime()}.xlsx`;
        link.click();
      })
    }
  }
}
</script>

<style scoped>

</style>
